const fs = require('fs');
const { createCanvas, loadImage } = require('canvas');
const sharp = require('sharp');

async function convertSvgToPng(svgPath, pngPath, size) {
  try {
    const svgBuffer = fs.readFileSync(svgPath);
    await sharp(svgBuffer)
      .resize(size, size)
      .png()
      .toFile(pngPath);
    console.log(`Converted ${svgPath} to ${pngPath}`);
  } catch (error) {
    console.error(`Error converting ${svgPath}:`, error);
  }
}

async function main() {
  const images = [
    { svg: 'images/logo.svg', png: 'images/logo.png', size: 160 },
    { svg: 'images/user.svg', png: 'images/user.png', size: 40 },
    { svg: 'images/password.svg', png: 'images/password.png', size: 40 },
    { svg: 'images/wechat.svg', png: 'images/wechat.png', size: 80 }
  ];

  for (const image of images) {
    await convertSvgToPng(image.svg, image.png, image.size);
  }
}

main().catch(console.error); 